import { myEnv } from '@/myEnv';
import { mergeRequest } from '@/utils';

type RequestParameters = {
    phoneNumber: string;
    captchaText: string;
};

/** 获取短信验证码 */
export const apiGetMessageCode = async (params) => {
    const response: MyResponse<any> = await sendRequest(params);
    return response;
};

const sendRequest = async (params: RequestParameters) => {
    let response: MyResponse<any>;
    if (myEnv.IS_ON_LINE) {
        response = await mergeRequest({
            url: `login/get-sms-verify-code?userPhoneNumber=${params.phoneNumber}&captchaText=${params.captchaText}`,
            method: 'GET',
        });
    } else {
        response = {
            code: '200',
            message: 'ok',
            data: {},
        };
    }
    return response;
};
